﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NeuralStock.DomainService.Interfaces;
using NeuralStock.DomainService;
using Microsoft.Practices.Unity;

namespace NeuralStock.Tests.Data
{
    [TestClass]
    public class CompanyQuotationDataTest
    {
        [TestMethod]
        public void CompanyQuotation_Rafako_ShouldHaveValidValues()
        {
            ICompanyService companyService = Bootstrapper.GetUnityContainer().Resolve<ICompanyService>();
            ICompanyQuotationService companyQuotationService = Bootstrapper.GetUnityContainer().Resolve<ICompanyQuotationService>();

            var companyId = companyService.Get("RAFAKO").Id;

            var quotation = companyQuotationService.Get(companyId, new DateTime(1997, 1, 2));
            Assert.AreEqual(16m, quotation.Price);

            quotation = companyQuotationService.Get(companyId, new DateTime(1997, 1, 4));
            Assert.AreEqual(null, quotation);
        }

        [TestMethod]
        public void CompanyQuotation_Advadis_ShouldHaveValidValues()
        {
            ICompanyService companyService = Bootstrapper.GetUnityContainer().Resolve<ICompanyService>();
            ICompanyQuotationService companyQuotationService = Bootstrapper.GetUnityContainer().Resolve<ICompanyQuotationService>();

            var companyId = companyService.Get("ADVADIS").Id;

            var quotation = companyQuotationService.Get(companyId, new DateTime(2001, 5, 16));
            Assert.AreEqual(2.53m, quotation.Price);
        }

        [TestMethod]
        public void CompanyQuotation_Impel_ShouldHaveValidValues()
        {
            ICompanyService companyService = Bootstrapper.GetUnityContainer().Resolve<ICompanyService>();
            ICompanyQuotationService companyQuotationService = Bootstrapper.GetUnityContainer().Resolve<ICompanyQuotationService>();

            var companyId = companyService.Get("IMPEL").Id;

            var quotation = companyQuotationService.Get(companyId, new DateTime(2013, 8, 30));
            Assert.AreEqual(30.0m, quotation.Price);
        }
    }
}
